#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:


    int citys(vector<vector<int> >& m) {
        int ret = 0;
        const int N = 210;
        bool vis[N] = { false };
        queue<int> q;
        for (int i = 0; i < m.size(); i++)
        {
            if (vis[i] == false)
            {
                q.push(i);
                vis[i] = true;
                while (q.size())
                {
                    int f = q.front();
                    q.pop();
                    for (int j = 0; j < m.size(); j++)
                    {
                        if (vis[j] == false && m[f][j] == 1)
                        {
                            vis[j] = true;
                            q.push(j);
                        }
                    }
                }
                ret++;
            }
        }
        return ret;
    }
};